#!/bin/make
#

#
# commands
#

RM = del /F /Q
AS = ca65
LD = ld65

#
# Flags
#

ASFLAGS = -t vic20 -g  -I .
LDFLAGS =  

#
# Sources
#

SID_SOURCES = sidemu.asm sidglue.asm sidload.asm
SID_OBJECTS = $(patsubst %.asm,%.o,$(SID_SOURCES))

SIDPLAY_SOURCES = sidemu.asm sidplay.asm
SIDPLAY_OBJECTS = $(patsubst %.asm,%.o,$(SIDPLAY_SOURCES))

TARGETS = sidemu.bin sidplay.prg

#
# targets
#

.PHONY : all clean install

all:	$(TARGETS)

install:

clean:
	$(RM) $(SID_OBJECTS) $(SIDPLAY_OBJECTS) $(TARGETS) $(patsubst %.bin,%.map,$(TARGETS)) $(patsubst %.bin,%.lbl,$(TARGETS))

sidemu.bin:		$(SID_OBJECTS) 
	$(LD) $(LDFLAGS) -C vic20-sid.cfg -m $(patsubst %.bin,%.map,$@) -Ln $(patsubst %.bin,%.lbl,$@) -o $@ $^

sidplay.prg:	$(SIDPLAY_OBJECTS) 
	$(LD) $(LDFLAGS) -C vic20-sidplay.cfg -m $(patsubst %.prg,%.map,$@) -Ln $(patsubst %.prg,%.lbl,$@) -o $@ $^

	
#
# Pattern rules
#

.SUFFIXES:
.SUFFIXES: .asm .o

%.o : %.asm
	$(AS) $(ASFLAGS) -o $@ $<
